﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace Dukou.Javascript
{
    public class JsIf : JsBase, IDisposable
    {
        public JsExpr LogicalExpression { get; private set; }

        public JsIf(HtmlHelper htmlHelper, JsExpr expr)
            : base(htmlHelper)
        {
            this.LogicalExpression = expr;
            this.Writer.WriteLine(string.Format("if ({0}) {{", expr));
        }

        public void Dispose()
        {
            this.Writer.WriteLine("}");
        }
    }

    public class JsElseIf : JsBase, IDisposable
    {
        public JsExpr LogicalExpression { get; private set; }

        public JsElseIf(HtmlHelper htmlHelper, JsExpr expr)
            : base(htmlHelper)
        {
            this.LogicalExpression = expr;
            this.Writer.WriteLine(string.Format("else if ({0}) {{", expr));
        }

        public void Dispose()
        {
            this.Writer.WriteLine("}");
        }
    }

    public class JsElse : JsBase, IDisposable
    {
        public JsElse(HtmlHelper htmlHelper)
            : base(htmlHelper)
        {
            this.Writer.WriteLine("else {");
        }

        public void Dispose()
        {
            this.Writer.WriteLine("}");
        }
    }
}
